<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of error_obj
 *
 * @author Juraj
 */
class error_obj {

    //put your code here

    private $error;
    private $function;
    private $class;

    public function __construct($data, $class, $function) {
        $this->error = $data;
        $this->function = $function;
        $this->class = $class;
        //debug_print_backtrace();
    }

    public function isError($object) {
        if (is_a($object, 'error_obj'))
            return true;
        return false;
    }
    
    public function setError($error,$description){
        if (!isset($GLOBALS['errors']))
            $GLOBALS['errors'] = array();
        if (!isset($GLOBALS['errors_alert']))
            $GLOBALS['errors_alert'] = array();
        $GLOBALS['errors'][] = $error;
        $GLOBALS['errors_alert'][] = $description;
    }
    
    public function setGood($message){
        if (!isset($GLOBALS['goods_alert']))
            $GLOBALS['goods_alert'] = array();
        $GLOBALS['goods_alert'][] = $message;
    }
    
    public function existError(){
        if (isset($GLOBALS['errors']) && !empty($GLOBALS['errors']))
            return true;
        return false;
    }
    
    public function getErrorData(){
        return array($this->error, $this->class, $this->function);
    }
    
    public static function smarty_printError($params){
        $temp = $params[error]->getErrorData();
        if ($params[id]==1)
            return 'Description => ' . $temp[0];
        if ($params[id]==2)
            return 'Action => ' . $temp[2];
        if ($params[id]==3)
            return 'Place => ' . $temp[1];
    }

}

?>
